package ws.com.pojo;

import com.constant.ResponseDataConstant;
import com.google.gson.Gson;
import com.responseData.R;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

public class WsResponse implements Encoder.Text<R<Object>>{

    public static R<Object> countPeople(Object value){
        return new R(ResponseDataConstant.WS_COUNT_PEOPLE,"成功",value , true);
    }

    public static R<Object> sendBarrage(Object value){
        return new R(ResponseDataConstant.WS_SEND_BARRAGE,"成功",value , true);
    }

    @Override
    public String encode(R<Object> objectR) throws EncodeException {
        return new Gson().toJson(objectR);
    }

    @Override
    public void init(EndpointConfig endpointConfig) {

    }

    @Override
    public void destroy() {

    }
}
